CREATE TABLE [dbo].[Provincia](
	[ProvinciaID] [int] NOT NULL,
	[ProvinciaNombre] [varchar](50) NOT NULL,
	[Activo] [bit] NOT NULL,
	[FechaAlta] [datetime] NOT NULL,
	[UsuarioAlta] [int] NOT NULL,
	[FechaModificacion] [datetime] NULL,
	[UsuarioModificacion] [int] NULL,
 CONSTRAINT [PK_Provincia] PRIMARY KEY CLUSTERED 
(
	[ProvinciaID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Provincia] ADD  CONSTRAINT [DF_Provincia_Activo]  DEFAULT ((1)) FOR [Activo]
GO

ALTER TABLE [dbo].[Provincia] ADD  CONSTRAINT [DF_Provincia_FechaAlta]  DEFAULT (getdate()) FOR [FechaAlta]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Partido](
	[PartidoID] [int] NOT NULL,
	[PartidoNombre] [varchar](100) NOT NULL,
	[ProvinciaID] [int] NOT NULL,
	[Activo] [bit] NULL,
	[FechaAlta] [datetime] NULL,
	[UsuarioAlta] [int] NULL,
	[FechaModificacion] [datetime] NULL,
	[UsuarioModificacion] [int] NULL,
 CONSTRAINT [PK_NPartido] PRIMARY KEY CLUSTERED 
(
	[PartidoID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Partido]  WITH CHECK ADD  CONSTRAINT [FK_Partido_Provincia] FOREIGN KEY([ProvinciaID])
REFERENCES [dbo].[Provincia] ([ProvinciaID])
GO

ALTER TABLE [dbo].[Partido] CHECK CONSTRAINT [FK_Partido_Provincia]
GO

ALTER TABLE [dbo].[Partido] ADD  CONSTRAINT [DF_Partido_Activo]  DEFAULT ((1)) FOR [Activo]
GO

ALTER TABLE [dbo].[Partido] ADD  CONSTRAINT [DF_Partido_FechaAlta]  DEFAULT (getdate()) FOR [FechaAlta]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Localidad](
	[LocalidadID] [int] NOT NULL,
	[LocalidadNombre] [varchar](100) NOT NULL,
	[Activo] [bit] NOT NULL,
	[FechaAlta] [datetime] NOT NULL,
	[UsuarioAlta] [int] NOT NULL,
	[FechaModificacion] [datetime] NULL,
	[UsuarioModificacion] [int] NULL,
	[PartidoID] [int] NULL,
 CONSTRAINT [PK_Localidad] PRIMARY KEY CLUSTERED 
(
	[LocalidadID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Localidad]  WITH CHECK ADD  CONSTRAINT [FK_Localidad_Partido] FOREIGN KEY([PartidoID])
REFERENCES [dbo].[Partido] ([PartidoID])
GO

ALTER TABLE [dbo].[Localidad] CHECK CONSTRAINT [FK_Localidad_Partido]
GO

ALTER TABLE [dbo].[Localidad] ADD  CONSTRAINT [DF_Localidad_Activo]  DEFAULT ((1)) FOR [Activo]
GO

ALTER TABLE [dbo].[Localidad] ADD  CONSTRAINT [DF_Localidad_FechaAlta]  DEFAULT (getdate()) FOR [FechaAlta]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Calle](
	[CalleID] [int] NOT NULL,
	[PartidoID] [int] NOT NULL,
	[CalleNombre] [varchar](150) NOT NULL,
	[CalleAlturaDesde] [varchar](10) NULL,
	[CalleAlturaHasta] [varchar](10) NULL,
	[CalleCategoria] [varchar](10) NULL,
	[Activo] [bit] NULL,
	[FechAlta] [datetime] NULL,
	[UsuarioAlta] [int] NULL,
	[FechaModificacion] [datetime] NULL,
	[UsuarioModificacion] [int] NULL,
 CONSTRAINT [PK_Ncalle] PRIMARY KEY CLUSTERED 
(
	[CalleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Calle]  WITH CHECK ADD  CONSTRAINT [FK_Calle_Partido] FOREIGN KEY([PartidoID])
REFERENCES [dbo].[Partido] ([PartidoID])
GO

ALTER TABLE [dbo].[Calle] CHECK CONSTRAINT [FK_Calle_Partido]
GO

ALTER TABLE [dbo].[Calle] ADD  CONSTRAINT [DF_Calle_Activo]  DEFAULT ((1)) FOR [Activo]
GO

ALTER TABLE [dbo].[Calle] ADD  CONSTRAINT [DF_Calle_FechAlta]  DEFAULT (getdate()) FOR [FechAlta]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TipoMovil](
	[TipoMovilID] [int] NOT NULL,
	[TipoMovilNombre] [varchar](50) NOT NULL,
	[Activo] [bit] NOT NULL,
	[FechaAlta] [datetime] NOT NULL,
	[UsuarioAlta] [int] NOT NULL,
	[FechaModificacion] [datetime] NULL,
	[UsuarioModificacion] [int] NULL,
 CONSTRAINT [PK_TipoMovil] PRIMARY KEY CLUSTERED 
(
	[TipoMovilID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[TipoMovil] ADD  CONSTRAINT [DF_TipoMovil_Activo]  DEFAULT ((1)) FOR [Activo]
GO

ALTER TABLE [dbo].[TipoMovil] ADD  CONSTRAINT [DF_TipoMovil_FechaAlta]  DEFAULT (getdate()) FOR [FechaAlta]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Movil](
	[MovilID] [int] IDENTITY(1,1) NOT NULL,
	[MovilNumero] [varchar](10) NOT NULL,
	[MovilPatente] [varchar](15) NOT NULL,
	[TipoMovilID] [int] NOT NULL,
	[MovilCostoHora] [decimal](18, 2) NOT NULL,
	[MovilCostoHoraPeon] [decimal](18, 2) NULL,
	[Activo] [bit] NOT NULL,
	[FechaAlta] [datetime] NOT NULL,
	[UsuarioAlta] [int] NOT NULL,
	[FechaModificacion] [datetime] NULL,
	[UsuarioModificacion] [int] NULL,
 CONSTRAINT [PK_Movil] PRIMARY KEY CLUSTERED 
(
	[MovilID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Movil]  WITH CHECK ADD  CONSTRAINT [FK_Movil_TipoMovil] FOREIGN KEY([TipoMovilID])
REFERENCES [dbo].[TipoMovil] ([TipoMovilID])
GO

ALTER TABLE [dbo].[Movil] CHECK CONSTRAINT [FK_Movil_TipoMovil]
GO

ALTER TABLE [dbo].[Movil] ADD  CONSTRAINT [DF_Movil_Activo]  DEFAULT ((1)) FOR [Activo]
GO

ALTER TABLE [dbo].[Movil] ADD  CONSTRAINT [DF_Movil_FechaAlta]  DEFAULT (getdate()) FOR [FechaAlta]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Chofer](
	[ChoferID] [int] IDENTITY(1,1) NOT NULL,
	[ChoferNombre] [varchar](50) NOT NULL,
	[ChoferApellido] [varchar](50) NOT NULL,
	[ChoferCalle] [varchar](100) NOT NULL,
	[ChoferCalleNumero] [varchar](10) NOT NULL,
	[ChoferPiso] [varchar](5) NULL,
	[ChoferDepartamento] [varchar](5) NULL,
	[LocalidadID] [int] NULL,
	[ChoferEmail] [varchar](100) NULL,
	[ChoferTelefono] [varchar](50) NULL,
	[ChoferCelular] [varchar](50) NULL,
	[Activo] [bit] NOT NULL,
	[FechaAlta] [datetime] NOT NULL,
	[UsuarioAlta] [int] NOT NULL,
	[FechaModificacion] [datetime] NULL,
	[UsuarioModificacion] [nchar](10) NULL,
 CONSTRAINT [PK_Chofer] PRIMARY KEY CLUSTERED 
(
	[ChoferID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Chofer]  WITH CHECK ADD  CONSTRAINT [FK_Chofer_Localidad] FOREIGN KEY([LocalidadID])
REFERENCES [dbo].[Localidad] ([LocalidadID])
GO

ALTER TABLE [dbo].[Chofer] CHECK CONSTRAINT [FK_Chofer_Localidad]
GO

ALTER TABLE [dbo].[Chofer] ADD  CONSTRAINT [DF_Chofer_Activo]  DEFAULT ((1)) FOR [Activo]
GO

ALTER TABLE [dbo].[Chofer] ADD  CONSTRAINT [DF_Chofer_FechaAlta]  DEFAULT (getdate()) FOR [FechaAlta]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Cliente](
	[ClienteID] [int] IDENTITY(1,1) NOT NULL,
	[ClienteRazonSocial] [varchar](100) NOT NULL,
	[ClienteCalle] [varchar](100) NOT NULL,
	[ClienteCalleNumero] [varchar](10) NULL,
	[ClientePiso] [varchar](5) NULL,
	[ClienteDepartamento] [varchar](5) NULL,
	[LocalidadID] [int] NOT NULL,
	[ClienteTelefono] [varchar](50) NULL,
	[ClienteContacto] [varchar](50) NULL,
	[Activo] [bit] NOT NULL,
	[FechaAlta] [datetime] NOT NULL,
	[UsuarioAlta] [int] NOT NULL,
	[FechaModificacion] [datetime] NULL,
	[UsuarioModificacion] [int] NULL,
 CONSTRAINT [PK_Cliente] PRIMARY KEY CLUSTERED 
(
	[ClienteID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Cliente]  WITH CHECK ADD  CONSTRAINT [FK_Cliente_Localidad] FOREIGN KEY([LocalidadID])
REFERENCES [dbo].[Localidad] ([LocalidadID])
GO

ALTER TABLE [dbo].[Cliente] CHECK CONSTRAINT [FK_Cliente_Localidad]
GO

ALTER TABLE [dbo].[Cliente] ADD  CONSTRAINT [DF_Cliente_Activo]  DEFAULT ((1)) FOR [Activo]
GO

ALTER TABLE [dbo].[Cliente] ADD  CONSTRAINT [DF_Cliente_FechaAlta]  DEFAULT (getdate()) FOR [FechaAlta]
GO


